feat: add server helpers, make connect() to default to parent post transport#165
Merged
feat: add server helpers, make connect() to default to parent post transport#165
Conversation
commit: |
f6b87cb to
b0e8518
Compare
b0e8518 to
163b09e
Compare
antonpk1
previously approved these changes
Dec 16, 2025
Add `src/server/` with convenience functions for registering MCP App tools and resources: - `registerAppTool(server, name, config, handler)` - `registerAppResource(server, name, uri, config, callback)` The `transport` parameter in `App.connect()` is now optional, defaulting to `PostMessageTransport(window.parent)`. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
163b09e to
f2bbb77
Compare
Co-authored-by: Jonathan Hefner <jonathan@hefner.pro>
b855340 to
c5fc927
Compare
Member
jonathanhefner
left a comment
There was a problem hiding this comment.
Food for thought: if there are other MCP extensions that similarly rely on _meta properties (on tools or resources), and they also want to define their own register*Tool() or register*Resource() helpers, those would clash ours.
A lighter-touch approach might be helper functions that accept and return preconfigured ToolConfig and ResourceMetadata objects. (Then you could write appToolConfig(fooToolConfig(barToolConfig({ ... }))).)
Anyway, not a blocker.
- Make RESOURCE_URI_META_KEY required in McpUiAppToolConfig (tools need a UI resource) - Make _meta optional in McpUiAppResourceConfig (not all resources need custom metadata) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
jonathanhefner
approved these changes
Dec 16, 2025
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Server Helpers (
src/server/)Add convenience functions for registering MCP App tools and resources:
registerAppTool(server, name, config, handler)- registers a tool with_meta[RESOURCE_URI_META_KEY]for the UI resource URIregisterAppResource(server, name, uri, config, callback)- registers a resource with default MIME typetext/html;profile=mcp-appThe helpers will allow transparent migrations, e.g. making #131 backwards-compatible + more type-safe (
uican be defined as a key onMcpUiAppToolConfig._meta, which otherwise only accepts indexed keys)Optional Transport in App.connect()
The
transportparameter inApp.connect()is now optional:PostMessageTransport(window.parent)when not providedawait app.connect()just worksExample Updates
Updated all examples to use the new helpers and package imports (
@modelcontextprotocol/ext-apps/server).Test plan
registerAppToolandregisterAppResourcenpm run build:all)🤖 Generated with Claude Code